package pag.client.ui;

import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

public class DrawTest extends JFrame
{
	
	private static final long serialVersionUID = 1552293588511518886L;
	private JPanel contentPane;
	private Image i;
	private JPanel panel;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args)
	{
		EventQueue.invokeLater(new Runnable() {
			public void run()
			{
				try
				{
					DrawTest frame = new DrawTest();
					frame.setVisible(true);
				}
				catch (Exception e)
				{
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public DrawTest()
	{
		
		initGUI();
	}
	private void initGUI() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		i = new ImageIcon(this.getClass().getResource("/pag/resources/1.png")).getImage();
		contentPane.setLayout(null);
		contentPane.add(getPanel());
	}
	private JPanel getPanel() {
		if (panel == null) {
			panel = new JPanel() {
				private static final long serialVersionUID = -4919408565549949423L;

				@Override
				protected void paintComponent(Graphics g)
				{
					super.paintComponent(g);
					
					Graphics2D g2 = (Graphics2D) g;
					g2.drawImage(i, 0, 0, 30, 45, getPanel());
					g2.rotate(Math.PI/3, 100, 100);
					g2.drawRect(0, 0, 50, 100);
				}
			};
			panel.setBackground(Color.MAGENTA);
			panel.setBounds(35, 30, 336, 185);
		}
		return panel;
	}
}
